#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;



void work(){
    string s;
    cin >> s;
    int cnt[256] = {0};
    for(auto c : s) ++cnt[c];
    if(cnt['A'] > cnt['B']) cout << "A\n";
    else cout << "B\n";
    return;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int nofkase = 1;
    cin >> nofkase;
    while(nofkase--) work();
    return 0;
}